var inival = 0; // Initialise starting element number
var groupnr = 0;
// Call this function to add textbox
function addTextBox() {
	var newArea = add_New_Element();
	groupnr += 1;
	var index = 1;
	var htcontents = "<table><tr><td>Nume Produs: </td><td><input type='text' name='"
			+ groupnr + "_" + index++ 
			+ "' required='required' id='autocompleteinput" + groupnr + "'/></td>"
			+ "<td>Cantitate: </td><td><input style='width: 30px' type='text' name='"
			+ groupnr + "_" + index++ 
			+ "' required='required'/></td>"
			+ "<td>Pret Intrare: </td><td><input style='width: 30px' type='text' name='"
			+ groupnr + "_" + index++ 
			+ "'  required='required'/></td></tr></table>";

	document.getElementById(newArea).innerHTML = htcontents;

}

function add_New_Element() {
	inival = inival + 1; // Increment element number by 1
	var ni = document.getElementById('area');
	var newdiv = document.createElement('div'); // Create dynamic element
	var divIdName = 'my' + inival + 'Div';
	newdiv.setAttribute('id', divIdName);
	ni.appendChild(newdiv);
	return divIdName;
}

function removeElement() {
	var d = document.getElementById('area');
	var olddiv = document.getElementById("my" + inival + "Div");
	d.removeChild(olddiv);
	if (inival != 0) {
		inival--;
	}
	if (groupnr != 0) {
		groupnr--;
	}

}

